// pages/index/index.js
var util = require("../../utils/util.js")
var api = require("../../utils/api.js")
var app = getApp();
Page({

    /**
     * 页面的初始数据
     */
    data: {
        imgarr: [],
        consult: [],
        resBaseUrl: '',
        articel: '',
        test: [],
        uresclass: [],
        current: 0,
		moreid:0,
    },
    theid: function(e) {
        wx.navigateTo({
			url: '../thetext/thetext?id=' + e.currentTarget.dataset.id,
        })
    },
    showconsult: function(e) {
        wx.navigateTo({
            url: '../development/development?id=' + e.currentTarget.dataset.id,
        })
    },
    changecurrent: function(e) {
        this.setData({
            current: e.currentTarget.current
        })
    },
    currentless: function(e) {
        if (this.data.current != 0) {
            this.setData({
                current: this.data.current - 1
            })
        } else {
            this.setData({
                current: this.data.classlength - 1
            })
        }
    },
    currentadd: function(e) {
        if (this.data.current != (this.data.classlength - 1)) {
            this.setData({
                current: this.data.current + 1
            })
        } else {
            this.setData({
                current: 0
            })
        }
    },
    jump: function(e) {
        wx.navigateTo({
            url: '../wptext/wptext?id=' + e.currentTarget.dataset.id + '&type=' + e.currentTarget.dataset.type,
        })
    },
	more:function(e){
		wx.navigateTo({
			url: '../more/more?type=' + e.currentTarget.dataset.id,
		})
	},
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function(options) {
        var that = this;
        that.setData({
            resBaseUrl: app.globalData.resBaseUrl
        })
        var info = {}
        var url = app.u.HOME_URL + app.u.INDEX
        api.requestUrl(info, url).then(res => {
            if (res.code == 200) {
                that.setData({
                    imgarr: res.data.adv.ad,
                    consult: res.data.consult,
                    articel: res.data.articel,
                    test: res.data.test,
                    uresclass: res.data.class,
                    classlength: res.data.class.length
                })
            }
        })
    },
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {
        wx.showShareMenu({
            withShareTicket: true
        })

    },
})